<template>
    <div class="box">
        <el-row>
            <el-col :span="24">
                <div class="header">
                    <el-form ref="form" :model="form" label-width="80px" class="flex-bettom">
                        <div class="flex">
                            <el-form-item label="网点名称">
                                <el-input v-model="form.name" placeholder="请输入网点名称" style="width:286px"></el-input>
                            </el-form-item>
                            <el-form-item label="日期范围" style="width:800px">
                                <el-date-picker v-model="value1" type="datetimerange" range-separator="至"
                                    start-placeholder="开始日期" end-placeholder="结束日期">
                                </el-date-picker>
                            </el-form-item>
                        </div>
                        <el-form-item>
                            <el-button type="primary" @click="onSubmit">查询</el-button>
                            <el-button>重置</el-button>
                        </el-form-item>
                    </el-form>
                </div>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="24" class="pie">
                <div style="padding-top: 20px" class="echart" ref="mychart" id="mychart"
                    :style="{ float: 'left', width: '100%', height: '320px' }"></div>
                <!-- <div class="button">
                    <el-button type="primary">收入</el-button>
                    <el-button type="primary">成本</el-button>
                </div> -->
            </el-col>
        </el-row>
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="明细" name="first">
                <el-row type="flex" justify="space-between">
                    <el-col :span="24">
                        <div>
                            当前页共10项
                        </div>
                    </el-col>
                    <el-col :span="5">
                        <div class="flex-end">
                            <el-button type="primary" @click="onSubmit">新增</el-button>
                            <el-button type="primary" @click="onSubmit">删除</el-button>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div>
                            <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
                                @selection-change="handleSelectionChange">
                                <el-table-column type="selection" width="55">
                                </el-table-column>
                                <el-table-column label="序号" width="120">
                                    <template slot-scope="scope">{{ scope.row.date }}</template>
                                </el-table-column>
                                <el-table-column prop="name" label="所属网点" width="120">
                                </el-table-column>
                                <el-table-column prop="address" label="配置名称" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column prop="name" label="导出类型" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="导出对象名称" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="自动导出日期" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="创建日期" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="操作" width="120">
                                </el-table-column>
                            </el-table>
                        </div>
                    </el-col>

                </el-row>
                <div class="block" style="display: flex; justify-content: end;">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100"
                        layout="total, sizes, prev, pager, next, jumper" :total="400">
                    </el-pagination>
                </div>
            </el-tab-pane>
            <el-tab-pane label="汇总" name="second">
                <el-row type="flex" justify="space-between">
                    <el-col :span="15">
                        <div>
                            当前页共10项
                        </div>
                    </el-col>
                    <el-col :span="4">
                        <div class="flex-end">
                            <el-button type="primary" @click="onSubmit">导出</el-button>
                            <el-button type="primary" @click="onSubmit">数据说明</el-button>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div>
                            <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
                                @selection-change="handleSelectionChange">
                                <el-table-column type="selection" width="55">
                                </el-table-column>
                                <el-table-column label="序号" width="120">
                                    <template slot-scope="scope">{{ scope.row.date }}</template>
                                </el-table-column>
                                <el-table-column prop="name" label="所属网点" width="120">
                                </el-table-column>
                                <el-table-column prop="address" label="配置名称" show-overflow-tooltip>
                                </el-table-column>
                                <el-table-column prop="name" label="导出类型" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="导出对象名称" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="自动导出日期" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="创建日期" width="120">
                                </el-table-column>
                                <el-table-column prop="name" label="操作" width="120">
                                </el-table-column>
                            </el-table>
                        </div>
                    </el-col>

                </el-row>
                <div class="block" style="display: flex; justify-content: end;">
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page="currentPage4" :page-sizes="[100, 200, 300, 400]" :page-size="100"
                        layout="total, sizes, prev, pager, next, jumper" :total="400">
                    </el-pagination>
                </div>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
import * as echarts from "echarts";

export default {
    data() {
        return {
            name: "张雪",
            activeName: 'first',

            xData: ["2020-02", "2020-03", "2020-04", "2020-05"], //横坐标数据
            yData: [30, 132, 80, 134], //纵坐标数据，与横坐标对应
            down: "下载操作手册",
            selectMonth: "",
            pendingList: [
                { num: 0, txt: "预付款" },
                { num: 0, txt: "物料申领" },
            ], //待审批项
            entranceList: [
                "出港结算",
                "进港结算",
                "结算关系配..",
                "报价维护",
                "站点预付款",
                "面单发放",
            ],
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                currentPage4: 4,
                desc: '',
                tableData: [{
                    date: '2016-05-03',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-02',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-04',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-01',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-08',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-06',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }, {
                    date: '2016-05-07',
                    name: '王小虎',
                    address: '上海市普陀区金沙江路 1518 弄'
                }],
            }
        };
    },
    mounted() {
        this.initEcharts();
    },
    methods: {
        // 柱状图
        initEcharts() {
      const option = {
        legend: {
          left: 'right',
          data: ['收入', '做量']
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#999'
            }
          }
        },
      
        xAxis: [
          {
            type: 'category',
            data: ['北京', '上海', '南京', '郑州', '苏州', '杭州', '广州'],
            axisPointer: {
              type: 'shadow'
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            name: '',
            min: 0,
            max: 250,
            interval: 50,
            axisLabel: {
              formatter: '{value} ml'
            }
          },
          {
            type: 'value',
            name: '',
            min: 0,
            max: 25,
            interval: 5,
            axisLabel: {
              formatter: '{value} °C'
            }
          }
        ],
        series: [
          {
            name: '收入',
            type: 'bar',
            barWidth: "15%",
            itemStyle: {
              color: "#2087D0",
              barBorderRadius: [10, 10, 0, 0],
            },
            tooltip: {
              valueFormatter: function (value) {
                return value + ' ml';
              }
            },
            data: [
              2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3
            ]
          },

          {
            name: '做量',
            type: 'line',
            yAxisIndex: 1,
            tooltip: {
              valueFormatter: function (value) {
                return value + ' °C';
              }
            },
            data: [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]
          }
        ]
      };
      const myChart = echarts.init(this.$refs.mychart); // 图标初始化
      myChart.setOption(option); // 渲染页面
      //随着屏幕大小调节图表
      window.addEventListener("resize", () => {
        myChart.resize();
      });
    },
    },

}
</script>

<style lang="scss" scoped>
.box {
    padding: 20px;
}

.flex {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
}

.flex-bettom {
    display: flex;
    justify-content: space-between;
}

.header {
    padding-bottom: 20px;
    border-bottom: 1px solid #ccc;
}

.el-row {
    margin-bottom: 20px;

    &:last-child {
        margin-bottom: 0;
    }
}

.el-col {
    border-radius: 4px;
}

.bg-purple-dark {
    background: #99a9bf;
}
.flex-end{
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.bg-purple {
    background: #d3dce6;
}

.bg-purple-light {
    background: #e5e9f2;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
}

.row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
}
</style>